
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author gjun
 */
public class ex1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        ArrayList<Integer> list=new ArrayList<>();
        
        System.out.println("輸入:");
        int x=sc.nextInt();

        for(int i=1;i<=x;i++)
        {
            System.out.println("第"+i+"個數字:");
            list.add(sc.nextInt());
        }
        
        Set uniqueSet = new HashSet(list);  
        for (Object temp : uniqueSet)
        {  
            System.out.println(temp + "出現" + Collections.frequency(list, temp)+"次");
        }        
    
    
    
}  static  {
        java.util.HashMap <String,Integer> map
     =new java.util.HashMap<>();
    map.put("1",1);
    map.put("2",1);
    map.put("3",2);
    map.put("4",3);
    map.put("5",3);
    map.put("6",4);
    map.put("7",5);
    map.put("8",5);
    map.put("9",6);
    map.put("10",7);
    map.put("11",7);
    map.put("12",8);
    map.put("13",9);
    map.put("14",10);
    map.put("15",11);
    Integer a=map.get("11");
    /* 1
       11
       111
       1111
       11111*/
    //程序目標運用管理:依循以上重覆排序法則
    //舉例:1件商品物件預做倉儲庫存管理:序號"10"顯示區域[7]第1個排序位置
    
    System.out.println(a);
    java.util.Set<String> set
            =map.keySet();
    java.util.Iterator<String> it
            =set.iterator();
    while(it.hasNext()){
        String key=it.next();
        Integer value=map.get(key);
        System.out.println(key+":"+value);
                
    }
}
}
